package com.itheima.mvc.controller;

import com.itheima.mvc.service.HelloService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

//交给spring容器管理
//Component
@Controller
@RequestMapping("hello")
public class HelloController {
    //怎么接收从参数

    @Autowired
    private HelloService helloService;
    //http://localhost:8080/hello

    @RequestMapping
    public String hello(){

        System.out.println("hello springmvc ....");
        helloService.hello();
        //跳转一个页面 String代表一个页面
        return "success.jsp";
    }

    ////http://localhost:8080/hello/getUser

    @RequestMapping("getUser")
    public String getUser(){

        System.out.println("hello getUser springmvc ....");
//        helloService.hello();
        //跳转一个页面 String代表一个页面
        return "/success.jsp";
    }
}
